package com.mark.converter;

import com.mark.dto.OrderDTO;
import com.mark.entity.OrderMaster;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * Created by Choisaaaa on 2018/6/22.
 * OrderMaster 和 OrderDTO之间的转换器
 */
public class OrderMaster2OrderDTOConverter {
    private OrderMaster2OrderDTOConverter(){}

    public static OrderDTO convert(OrderMaster orderMaster){
        OrderDTO orderDTO = new OrderDTO();
        BeanUtils.copyProperties(orderMaster,orderDTO);
        return orderDTO;
    }

    public static List<OrderDTO> convert(List<OrderMaster> orderMasterList){
        return orderMasterList.stream().map(
                e -> convert(e)
        ).collect(Collectors.toList());
    }
}
